package com.xzan.medusaweb.controller;

import com.xzan.medusa.common.query.BaseQuery;
import com.xzan.medusa.common.query.PageResult;
import com.xzan.medusa.core.manager.CcCarManager;
import com.xzan.medusa.dal.model.CcCarDO;
import com.xzan.medusa.dal.query.CcCarQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class LoginCotroller {
    @Autowired
    private CcCarManager ccCarManager;
    @Autowired
    private StringRedisTemplate redisTemplate;

    @RequestMapping("/login.do")
    public String login() {
        CcCarQuery ccCarQuery = new CcCarQuery();
        ccCarQuery.createCriteria().anCarIdGreaterThan(3L);
        ccCarQuery.setPageNo(BaseQuery.DEFAULT_PAGE);
        ccCarQuery.setPageSize(BaseQuery.DEFAULT_PAGE_SIZE);
        PageResult<CcCarDO> pageCarDOs = ccCarManager.selectByQueryWithPage(ccCarQuery);
        List<CcCarDO> carDoList=pageCarDOs.getResult();
        carDoList.forEach(ccCarDO -> {
            System.out.println(ccCarDO.getBrandName());
        });
       ValueOperations<String,String> valueOperations= redisTemplate.opsForValue();
       System.out.println(valueOperations.get("1"));
        return "views/login_simple";

    }

}
